package cn.bdqn.study_method;

import java.util.Scanner;

//计算成绩的类
public class ScoreCalc {
    public int java;
    public int c;
    public int db;

    //求三门成绩的和
    public int getSum() {
        int sum = java + c + db;
        return sum;
    }

    //求平均值
    public double getAvg() {
        //同一个类中，方法可以直接被调用
        int sum = getSum();
        double avg = sum / 3.0;
        return avg;
    }

    public static void main(String[] args) {
        ScoreCalc sc = new ScoreCalc();
        Scanner input = new Scanner(System.in);
        System.out.println("请输入java成绩：");
        sc.java = input.nextInt();
        System.out.println("请输入C#成绩：");
        sc.c = input.nextInt();
        System.out.println("请输入db成绩：");
        sc.db = input.nextInt();
        int sum = sc.getSum();
        System.out.println("总分是：" + sum);
        double avg = sc.getAvg();
        System.out.println("平均值：" + avg);
    }

}
